package com.qf.oop.dt;

public class Rectangle extends Graphical {

    private String name; // 名字
    private int length; // 长
    private int width; // 宽
    private double c; // 周长
    private double area; // 面积


    /**
     * 初始化并且计算周长和面积
     */
    public Rectangle() {
        setName("矩形");
        setLength(4);
        setWidth(3);
        calcPerimeter();
        calcArea();
    }

    /**
     * 打印信息
     */
    public void printInfo() {
        System.out.print("名称:" + getName());
        System.out.print(" 长:" + length);
        System.out.print(" 宽:" + width);
        System.out.print(" 周长:" + getC());
        System.out.println(" 面积:" + getArea());
    }

    /**
     * 计算周长
     */
    public void calcPerimeter() {
        setC(2 * getWidth() + 2 * getLength());
    }

    /**
     * 计算面积
     */
    public void calcArea() {
        setArea(getWidth() * getLength());
    }

    public Rectangle(String name, int length, int width, double c, double area) {
        this.name = name;
        this.length = length;
        this.width = width;
        this.c = c;
        this.area = area;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getLength() {
        return length;
    }

    public void setLength(int length) {
        this.length = length;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public double getC() {
        return c;
    }

    public void setC(double c) {
        this.c = c;
    }

    public double getArea() {
        return area;
    }

    public void setArea(double area) {
        this.area = area;
    }
}
